package database

import (
	"github.com/glebarez/sqlite"
	"gorm.io/gorm"
	"log"
)

type SqliteHelper struct {
	DBName string
	DB     *gorm.DB
}

func CreateSqliteHelper(dbName string) *SqliteHelper {
	db, err := gorm.Open(sqlite.Open(dbName), &gorm.Config{})
	if err != nil {
		log.Println("Open", err)
		return nil
	}
	s := &SqliteHelper{
		DBName: dbName,
		DB:     db,
	}
	return s
}

func (s *SqliteHelper) CreateTable() {
	_ = s.DB.AutoMigrate(&User{}, &OtaInfo{})
}
